package com.lzw.breezeNovel.webApp.controller.novel;

import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.webApp.service.novel.BookSelfService;
import com.lzw.breezeNovel.webApp.vo.novel.BookVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller
 * @date 2025/3/2
 * @description 书架的控制类
 */
@RestController
@RequestMapping("/app/bookSelf")
@SuppressWarnings("all")
public class BookSelfController {

    /**
     * 注入BookSelfService
     */
    @Autowired
    private BookSelfService bookSelfService;


    /**
     * 获取书架里面的所有的小说
     * @return
     */
    @GetMapping("/getBookSelf")
    private Result<List<BookVo>> getBooks(){
        List<BookVo>  bookVos  = bookSelfService.getBookSelf();
        return Result.ok(bookVos);
    }

    /**
     * 根据小说id从书架里面删除小说
     */
    @DeleteMapping("/deleteBook")
    private Result deleteBook(@RequestParam("bookId") Long bookId){
        bookSelfService.deleteBook(bookId);
        return Result.ok();
    }

    /**
     * 根据小说id添加小说
     */
    @GetMapping("/addBook")
    private Result addBook(@RequestParam("bookId") Long bookId){
        bookSelfService.addBook(bookId);
        return Result.ok();
    }
}
